home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / 3rdparty / tools / library / memo_prt.clw < prev    next >
Encoding:
Text File  |  1995-10-23  |  7.0 KB  |  209 lines

  1.            MEMBER('TestMemo.clw')         ! This is a MEMBER module
  2. MemoPrint          PROCEDURE
  3.  
  4. !!!!!! Prototype for API used:  SendMessage(USHORT,USHORT,USHORT,ULONG),ULONG,PASCAL
  5.  
  6. EM_GetLineCount      EQUATE(040Ah)
  7. EM_GetLine           EQUATE(0414h)
  8. memofield            STRING(10000)
  9. memoline             STRING(255)
  10. PrintDate            DATE
  11.  
  12. RejectRecord         LONG,AUTO
  13. LocalRequest         LONG,AUTO
  14. LocalResponse        LONG,AUTO
  15. WindowOpened         LONG,AUTO
  16. RecordsToProcess     LONG,AUTO
  17. RecordsProcessed     LONG,AUTO
  18. RecordsPerCycle      LONG,AUTO
  19. RecordsThisCycle     LONG,AUTO
  20. PercentProgress      DECIMAL(4,1)
  21. RecordStatus         BYTE,AUTO
  22. !-----------------------------------------------------------------------------
  23. Report REPORT,AT(15,21,180,249),PRE(RPT),FONT('Arial',8,,FONT:regular),MM
  24.        HEADER,AT(15,,180,21),FONT('Arial',10,,)
  25.          STRING('Example of Memo Printing Report'),AT(8,0,129,),FONT('Arial',16,,FONT:bold),USE(?Header1), |
  26.              TRN,LEFT
  27.          STRING('Date:'),AT(8,10,10,4),FONT('Arial',10,,FONT:bold),USE(?Title1)
  28.          STRING(@d5),AT(21,10,17,4),FONT('Arial',10,,FONT:regular),USE(PrintDate)
  29.        END
  30. detail DETAIL,AT(,,,10),FONT('Arial',10,,FONT:regular),USE(?detail)
  31.          STRING(@n4),AT(8,4,10,4),FONT('Arial',10,,FONT:bold),USE(ite:number)
  32.          STRING(@s35),AT(29,4,88,4),FONT('Arial',10,,FONT:regular),USE(ite:header)
  33.        END
  34. ldetail DETAIL,AT(,,,3),FONT('Arial',10,,),USE(?ldetail)
  35.          TEXT,AT(40,0,170,),FONT('Arial',10,,FONT:regular),USE(?ite:description)
  36.          STRING(@S255),AT(40,0,170,),FONT('Arial',10,,FONT:regular),USE(memoline)
  37.        END
  38.        FOOTER,AT(15,270,180,10),USE(?footer)
  39.          STRING('Page:'),AT(10,2,,),FONT('Arial',10,,FONT:regular),USE(?Title9)
  40.          STRING(@n2),AT(23,2,8,4),FONT('Arial',10,,FONT:regular),PAGENO,USE(?String26)
  41.        END
  42.      END
  43.  
  44. !!!! After Report Declaration Embed Point
  45. window WINDOW('Window for text Measuring'),AT(3,24,394,51),STATUS,TIMER(1),SYSTEM,GRAY,MASK,MODAL
  46.        TEXT,AT(10,5,195,38),FONT('Arial',8,,FONT:regular+FONT:italic),USE(memofield),HIDE
  47.      END
  48. !!!! End of Embed Point
  49.  
  50. ProgressWindow       WINDOW('Progress...'),AT(,,142,59),CENTER,TIMER(1),GRAY,DOUBLE
  51.                        STRING(''),AT(0,3,141,10),USE(?Progress:UserString),CENTER
  52.                        BOX,AT(15,15,111,12),COLOR(00H),FILL(0FFFFFFH)
  53.                        BOX,AT(21,18,100,6),COLOR(00H),FILL(0C0C0C0H)
  54.                        BOX,AT(21,18,100,6),USE(?Progress:Thermometer),FILL(0FFH)
  55.                        STRING(''),AT(0,30,141,10),USE(?Progress:PctText),CENTER
  56.                        BUTTON('Cancel'),AT(45,42,50,15),USE(?Progress:Cancel)
  57.                      END
  58.   CODE
  59.   LocalRequest = GlobalRequest
  60.   LocalResponse = RequestCancelled
  61.   CLEAR(GlobalRequest)
  62.   CLEAR(GlobalResponse)
  63.   IF items::Used = 0
  64.     CheckOpen(items,1)
  65.   END
  66.   items::Used += 1
  67.   IF sysgen::Used = 0
  68.     CheckOpen(sysgen,1)
  69.   END
  70.   sysgen::Used += 1
  71.  
  72.   PrintDate = TODAY()
  73.   RecordsToProcess = RECORDS(items)
  74.   RecordsPerCycle = 25
  75.   RecordsProcessed = 0
  76.   PercentProgress = 0
  77.   CLEAR(ite:record)
  78.   OPEN(ProgressWindow)
  79.   ?Progress:Thermometer{Prop:Width} = 0
  80.   ?Progress:PctText{Prop:Text} = '0.0% Completed'
  81.   ProgressWindow{Prop:Text} = 'Printing Report'
  82.   ?Progress:UserString{Prop:Text}=''
  83.   ACCEPT
  84.     CASE EVENT()
  85.     OF Event:OpenWindow
  86.       CLEAR(ite:record,-1)
  87.       SET(ite:by_number,ite:by_number)
  88.       LOOP
  89.         DO GetNextitems
  90.         DO ValidateRecord
  91.         EXECUTE RecordStatus
  92.           BEGIN
  93.             LocalResponse = RequestCancelled
  94.             BREAK
  95.           END
  96.           CYCLE
  97.         END
  98.         BREAK
  99.       END
  100.       IF LocalResponse = RequestCancelled
  101.         POST(Event:CloseWindow)
  102.         CYCLE
  103.       END
  104.       !!!! Before Opening Report Embed Point
  105.       SET(sysgen)
  106.       NEXT(sysgen)
  107.       IF ERROR() THEN STOP(ERROR()).
  108.       !!!! End of Embed
  109.       OPEN(Report)
  110.       !!!! After Opening Report Embed Point
  111.       SETTARGET(report)
  112.       !!!! End of Embed
  113.     OF Event:Timer
  114.       LOOP RecordsPerCycle TIMES
  115.         PRINT(RPT:detail)
  116.         !!!! After Printing Detail Section Embed Point
  117.         Memofield = ite:description                         ! ite:description is the memo field
  118.         OPEN(Window)
  119.         window{prop:hide} = true
  120. !        window$?memofield{prop:at,3} = sys:memowidth       !This sets the width which gets
  121.                                                             !printed and is font dependent.
  122.                                                             !If only one font is to be used then
  123.                                                             !the appropriate width can be fixed
  124.                                                             !in the window itself.
  125.         handle# = window$?memofield{prop:handle}
  126.         lines# = SendMessage(handle#,EM_GETLINECOUNT,0,0)
  127.         LOOP I# = 0 TO LINES#-1
  128.           len# = SendMessage(handle#,EM_GETLINE,I#,ADDRESS(memoline))
  129.           memoline[len#+1] = CHR(0)
  130.           PRINT(rpt:ldetail)
  131.         END
  132.         CLOSE(window)
  133.         !!!! End of Embed Point
  134.         LOOP
  135.           DO GetNextRecord
  136.           DO ValidateRecord
  137.           EXECUTE RecordStatus
  138.             BEGIN
  139.               LocalResponse = RequestCancelled
  140.               BREAK
  141.             END
  142.             CYCLE
  143.           END
  144.           BREAK
  145.         END
  146.         IF LocalResponse = RequestCancelled
  147.           LocalResponse = RequestCompleted
  148.           BREAK
  149.         END
  150.         LocalResponse = RequestCancelled
  151.       END
  152.       IF LocalResponse = RequestCompleted
  153.         POST(Event:CloseWindow)
  154.       END
  155.     END
  156.     CASE FIELD()
  157.     OF ?Progress:Cancel
  158.       CASE Event()
  159.       OF Event:Accepted
  160.         LocalResponse = RequestCancelled
  161.         POST(Event:CloseWindow)
  162.       END
  163.     END
  164.   END
  165.   CLOSE(Report)
  166.   DO ProcedureReturn
  167. ProcedureReturn ROUTINE
  168.   items::Used -= 1
  169.   IF items::Used = 0 THEN CLOSE(items).
  170.   sysgen::Used -= 1
  171.   IF sysgen::Used = 0 THEN CLOSE(sysgen).
  172.   IF LocalResponse
  173.     GlobalResponse = LocalResponse
  174.   ELSE
  175.     GlobalResponse = RequestCancelled
  176.   END
  177.   RETURN
  178. !-----------------------------------------------------------------------------
  179. ValidateRecord       ROUTINE
  180.   RecordStatus = Record:OutOfRange
  181.   IF LocalResponse = RequestCancelled THEN EXIT.
  182.   IF ERRORCODE() THEN EXIT.
  183.   RecordStatus = Record:OK
  184.   EXIT
  185. GetNextitems ROUTINE
  186.   LocalResponse = RequestCancelled
  187.   LOOP
  188.     NEXT(items)
  189.     IF ERRORCODE() THEN EXIT.
  190.     RecordsProcessed += 1
  191.     RecordsThisCycle += 1
  192.     IF PercentProgress < 100
  193.       PercentProgress = (RecordsProcessed / RecordsToProcess)*100
  194.       IF PercentProgress > 100
  195.         PercentProgress = 100
  196.       END
  197.       ?Progress:Thermometer{Prop:Width} = ROUND(PercentProgress,0)
  198.       ?Progress:PctText{Prop:Text} = FORMAT(PercentProgress,@N5.1) & '% Completed'
  199.       DISPLAY()
  200.     END
  201.     BREAK
  202.   END
  203.   LocalResponse = RequestCompleted
  204.   EXIT
  205.  
  206. GetNextRecord ROUTINE
  207.   DO GetNextitems
  208.   IF LocalResponse = RequestCompleted THEN EXIT.
  209.